#include<at89c51ed2.h>
#include<mcs51reg.h>
#include "spi.h"
#include "sst25vf080b.h"
#include "io.h"
#include <stdio.h>




	int readByte(int addrH,int addrM,int addrL)
	{
	int rxData;
	
	Master_spi_init(2); //for memory chip*/
	spiChipSelectON(2);
	sstDataReadRegisterSet(0x03);
		
	spi_dataSend(addrH);
	spi_dataSend(addrM);
	spi_dataSend(addrL);
	
	rxData=sstDataReadVal();

	//printf("rxDATa %d\n\r",rxData);
	spiChipSelectOFF(2);
	
	Master_spi_init(1); //for rssi chip,restored*/
	return rxData;	
	}

/***example usage*************/
//spiChipSelectON(2);
//setMultipleRead(254,20,11);
//test=readMultipleByte();
//spiChipSelectOFF(2);
/*****************************/

/*not using these!! */
void setMultipleRead(int addrH,int addrM,int addrL)
{
	Master_spi_init(2); //for memory chip*/
	sstDataReadRegisterSet(0x03);
	
	spi_dataSend(addrH);
	spi_dataSend(addrM);
	spi_dataSend(addrL);
}


/**must use chip select on and off for these below two functions*/
int readMultipleByte()
{
	int rxData;

	rxData=sstDataReadVal();
	Master_spi_init(1); //for rssi chip,restored*/
	return rxData;
}
	

